package com.cs.controller;

import com.cs.anno.Log;
import com.cs.domain.SysRole;
import com.cs.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "后台角色管理的接口")
@RequestMapping("/sys/role")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    /**
     * 查询所有的角色 需要加缓存
     * @return
     */
    @ApiOperation(value = "查询所有的角色的接口")
    @GetMapping("/list")
    @PreAuthorize("hasAuthority('sys:role:list')")
    @Log(value ="查询所有的角色 ")
    public ResponseEntity<List<SysRole>> findListRole(){
        List<SysRole> roleList=sysRoleService.findListRole();
        return ResponseEntity.ok(roleList);
    }

}
